package com.fenghongzhang.kuaishou.index.home.presenter;

import android.util.Log;

import com.fenghongzhang.kuaishou.index.home.contract.OptimalFragmentContract;
import com.fenghongzhang.kuaishou.index.home.entity.VideoBean;
import com.fenghongzhang.mvp_lib.presenter.BasePresenter;

import java.util.Arrays;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class OptimalPresenter extends BasePresenter<OptimalFragmentContract.IOptimalModel,OptimalFragmentContract.IOptimalView> {

    private static final String TAG = "OptimalPresenter";


    public OptimalPresenter(OptimalFragmentContract.IOptimalModel mModel, OptimalFragmentContract.IOptimalView mView) {
        super(mModel, mView);
    }

    public void getVideoList(){

        mModel.getVideoList(new Observer<VideoBean[]>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(VideoBean[] videoBeans) {
                Log.i(TAG, "onNext: "+videoBeans.length);
                mView.initAdapter(Arrays.asList(videoBeans));
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });

    }
}
